package compiler;

import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class Excel {
	
	public String[][] excelProceso(String file) throws BiffException, IOException {
		String[][] proceso = new String[28][25];
		Workbook workbook = Workbook.getWorkbook(new File(file));
		Sheet sheet = workbook.getSheet("Sheet1");
		
		for(int i=33; i < 61; i++) {
			for(int j=2; j < 27; j++) {
				Cell cell = sheet.getCell(j,i);
				proceso[i-33][j-2] = cell.getContents();
			}
		}
        workbook.close();
		return proceso;
	}
	
	public int[][] excelNuevoEstado(String file) throws BiffException, IOException {
		int[][] nuevo_estado = new int[28][25];
		Workbook workbook = Workbook.getWorkbook(new File(file));
		Sheet sheet = workbook.getSheet("Sheet1");
		
		for(int i=2; i < 30; i++) {
			for(int j=2; j < 27; j++) {
				Cell cell = sheet.getCell(j,i);
				String content = cell.getContents();
				int val;
				if(content.isEmpty()) 
					val = -1;
				else
					val = Integer.parseInt(cell.getContents());
				nuevo_estado[i-2][j-2] = val;
			}
		}
        workbook.close();
		return nuevo_estado;
	}
}
